import os
lis = os.listdir()
s='''# 解题代码\n\n'''
for i in lis:
    if not i.endswith("py"):
        s+="## "+i.split("——")[1]+"\n\n"
        lis1 = os.listdir(i)
        for j in lis1:
            if ".cpp" or ".c" in j:
                s+="### "+j.split(".")[0]+"\n\n"
                s+="```c++\n"
                try:
                    with open(i+"/"+j,'r') as f:
                        s+=f.read()
                except:
                    print(i+"/"+j)
                s+="\n```\n\n"
            if ".py" in j:
                s+="### "+j.split(".")[0]+"\n\n"
                s+="```python\n"
                try:
                    with open(i+"/"+j,'r') as f:
                        s+=f.read()
                except:
                    print(i+"/"+j)
                s+="\n```\n\n"
            if ".java"in j:
                s+="### "+j.split(".")[0]+"\n\n"
                s+="```java\n"
                try:
                    with open(i+"/"+j,'r') as f:
                        s+=f.read()
                except:
                    print(i+"/"+j)
                s+="\n```\n\n"
with open("answer.md",'w')as f:
    f.write(s)
